﻿using AutoMapper;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Logging;
using NetTaste;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Security.Cryptography;
using System.Security.Policy;
using System.Text.RegularExpressions;
using VM.BLL.Menu;
using VM.Common.DataUntil;
using VM.Common.EntityEnum;
using VM.Common.Result;
using VM.DAL.System.Code;
using VM.Entity.EntityDto.ICon;
using VM.Entity.EntityMap.DataBase;
using VM.Entity.EntityMap.ICon;
using VM.Entity.EntityMap.Member;
using VM.Entity.EntityMap.Menu;
using VM.Entity.EntityMap.MsgCode;
using VM.Entity.EntityMap.Region;
using VM.Entity.EntityMap.System.Code;
using VM.Entity.EntityMap.Token;
using VM.Entity.EntityMap.Topic;
using VM.IBLL.ICon;
using VM.IBLL.Member;
using VM.IBLL.Menu;
using VM.IBLL.Token;
using VM.IBLL.Topic;
using VM.IDAL;
using VM.IDAL.ICon;


using static Dm.net.buffer.ByteArrayBuffer;

namespace VM.BLL.ICon
{
    public class IConBLL : BaseBLL, IIconBLL
    {

        private readonly ISqlSuggarDAL _ISqlSuggarDAL;
        private readonly IIconDAL _IIconDAL;
        private readonly IMapper _IMapper;
        public IConBLL(ISqlSugarClient client, ISqlSuggarDAL sqlSuggarDAL, IMenuBLL iMenuBLL, IIconDAL iIconDAL, IMapper iMapper)
        {
            _ISqlSuggarDAL = sqlSuggarDAL;
            _IIconDAL = iIconDAL;
            _IMapper = iMapper;


        }

        public ApiResult addIcon(addIconDto obj)
        {
            sys_icon objRes = _IMapper.Map<addIconDto, sys_icon>(obj);
            ApiResult res = new ApiResult();
            int Res = _IIconDAL.addIcon(objRes);
            if (Res > 0)
            {
                res.code = 200;
                res.msg = $@"成功插入{Res}条数据";

            }
            else
            {
                res.code = 403;
                res.msg = $@"成功失败";

            }
            return res;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="name"></param>
        /// <param name="userId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public ApiDataResult<PagingData<getIconListDto>> getIconList(string? name, int userId, int pageSize, int pageIndex)
        {
            ApiDataResult<PagingData<getIconListDto>> res = new ApiDataResult<PagingData<getIconListDto>>();

            PagingData<sys_icon> dataRes = _IIconDAL.getIconList(name, userId, pageSize, pageIndex);

            PagingData<getIconListDto> data = _IMapper.Map<PagingData<sys_icon>, PagingData<getIconListDto>>(dataRes);
            res.code = 200;
            res.data = data;
            res.msg = "查询成功";
            return res;

        }
    }
}




